package jm.nj.demo18main.demo03;

import jm.nj.demo18main.demo01.User;
import jm.nj.demo18main.demo03.MyBeanUtils;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/*
 * 测试自定义的MyBeanUtils工具类
 */
public class TestMyBeanUtils {
    @Test
    public void demo02(){
        //User user = new User();

        Map<String,String[]> properties = new HashMap<String, String[]>();
        properties.put("id",new String[]{"1231","007"});
        properties.put("user",new String[]{"rose"});
        properties.put("password",new String[]{"1234"});
        properties.put("hobbies",new String[]{"早晨敲代码","中午敲代码","晚上敲代码","梦中敲代码"});

        User user= MyBeanUtils.populate03(User.class,properties);
        System.out.println(user);
    }

    @Test
    public void demo03(){
        //User user = new User();

        Map<String,String[]> properties = new HashMap<String, String[]>();
        properties.put("id",new String[]{"1231","007"});
        properties.put("user",new String[]{"rose"});
        properties.put("password",new String[]{"1234"});
        properties.put("hobbies",new String[]{"早晨敲代码","中午敲代码","晚上敲代码","梦中敲代码"});

        User user= (User) MyBeanUtils.populate02(User.class,properties);
        System.out.println(user);
    }

    @Test
    public void demo01(){
        User user = new User();

        Map<String,String[]> properties = new HashMap<String, String[]>();
        properties.put("id",new String[]{"1231","007"});
        properties.put("user",new String[]{"rose"});
        properties.put("password",new String[]{"1234"});
        properties.put("hobbies",new String[]{"早晨敲代码","中午敲代码","晚上敲代码","梦中敲代码"});

        MyBeanUtils.populate01(user,properties);
        System.out.println(user);
    }

}
